package com.game.module.gameTask.view
{
	import com.dusk.util.ResUtil;
	import com.dusk.util.TextUtil;
	import com.game.module.gameTask.vo.TaskVO;
	import com.game.view.component.ComponentBase;
	
	import flash.display.Bitmap;
	import flash.display.MovieClip;
	import flash.text.TextField;
	
	public class TaskTitle extends ComponentBase
	{
		
		public function TaskTitle()
		{
			super();
		}
		
		public var taskNameTxt:TextField;
		private var myTask:TaskVO;
		private var texture:MovieClip;
		
		override protected function beforeAdded():void
		{
			texture = ResUtil.getComponentView("TaskTitle") as MovieClip;
			TextUtil.redrawTxt(texture);
			taskNameTxt = texture.getChildByName("taskNameTxt") as TextField;
			texture.gotoAndStop(1);
			addChild(texture);
		}
		
		public function setTask(param1:TaskVO):void
		{
			this.myTask = param1;
			this.taskNameTxt.text = this.myTask.getrwname();
			this.setReceive();
		}
		
		public function selected():void
		{
			texture.gotoAndStop(2);
		}
		
		public function unselected():void
		{
			texture.gotoAndStop(1);
		}
		
		public function getTask():TaskVO
		{
			return this.myTask;
		}
		
		public function setReceive():void
		{
				if (myTask && myTask.getHasGetAward())
				{
					var bm:Bitmap = ResUtil.getImageBitmap("hasReceive");
					bm.name = "hasReceiveIcon";
					bm.x = 150.5;
					addChild(bm);
				}
				else if (this.getChildByName("hasReceiveIcon"))
				{
					this.removeChild(this.getChildByName("hasReceiveIcon"));
				}
		}
		
		public function removeIcon():void
		{
			if (getChildByName("hasReceiveIcon"))
			{
				removeChild(getChildByName("hasReceiveIcon"));
			}
		}
	}
}
